<%@include file="/WEB-INF/views/includes/taglibs.jsp"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@include file="/WEB-INF/views/includes/adminHeader.jsp"%>



<!--[if gte IE 6]>
<script>
$(document).ready( function() {
$(".dataRow").mouseover(function(){$(this).addClass("dataRowOver");});
$(".dataRow").mouseout(function(){$(this).removeClass("dataRowOver");});
});
</script>
<![endif]-->
<script type="text/javascript">

function editBizGroup(id) {
	window.location.href = "<c:url value='/web/editBizGroup?id='/>" + id;
}
function editBizGroupFilter(id) {
	window.location.href = "<c:url value='/web/editFilterRule?bizGroupId='/>" + id;
}


</script>
<div class="homePage ui-tabs-panel ui-widget-content ui-corner-bottom">
	<div id="leftMenu">
		<%@include file="/WEB-INF/views/includes/bizGroupAdminLeftNav.jsp"%>
	</div>
	<div id="rightContent">
		<%@include file="/WEB-INF/views/includes/messages.jsp"%>
		<h2>Business Group List</h2>
		<div class="searchBlock">
				<form:form method="post" action="bizgroupHome" id="searchBizgroupform">
					<form:label path="name">Business Group Name</form:label>&nbsp;
					<form:input path="name"/>&nbsp;&nbsp;
					<br/>
					<button type="button"
						class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
						onclick="save()" style="margin-top:5px">
						<span class="ui-button-text">Search Business Group</span>
					</button>&nbsp;&nbsp;&nbsp;&nbsp;
					<button type="button"
						class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
						onclick="createNewGroup()">
						<span class="ui-button-text">Create new Business Group</span>
					</button>
					<script type="text/javascript">
						function save() {
							$('#searchBizgroupform').submit();
						}
						
						function createNewGroup() {
							window.location.href = "<c:url value='/web/createBizGroup'/>";
						}
					</script>
				</form:form>
		</div>
		<div>
			<table class="generaltable" style="width:100%" cellspacing="0" cellpadding="0">
				<thead>
					<tr>
						<th>Group Name</th>
						<th>Parent Name</th>
						<th>Assigned Functions</th>
						<th>Description</th>
						<th>Operations</th>
					</tr>
				</thead>
				<tbody>
				<c:if test="${not empty bizGroupList}">
					<c:forEach items="${bizGroupList}" var="oneBizGroup">
					<tr class="dataRow">
						<td>${oneBizGroup.name}</td>
						<td>${oneBizGroup.parentName}</td>
						<td><a href="<c:url value='/web/assignFunctions'/>?bizGroupId=${oneBizGroup.id}">${oneBizGroup.functionCount} (click for details)</a><br/>
						<c:if test="${oneBizGroup.customized==0}">
							extends from ${oneBizGroup.customizedParentName}
						</c:if>
						</td>
						<td>${oneBizGroup.description}</td>
						<td>
						<c:if test="${oneBizGroup.root==1}">
							Root Group cannot be updated
						</c:if>
						<c:if test="${oneBizGroup.root==0}">
							<a href="#" onclick="editBizGroup('${oneBizGroup.id}')">Edit</a>&nbsp;&nbsp;
							<a href="<c:url value='/web/assignFunctions'/>?bizGroupId=${oneBizGroup.id}">Assign functions</a>&nbsp;&nbsp;
							<a href="#" onclick="editBizGroupFilter('${oneBizGroup.id}')">Filter Rule</a>
						</c:if>
						</td>
					</tr>
					</c:forEach>
				</c:if>
				</tbody>
			</table>
		</div>
		<div style="height:1px;width:740px;"></div>
	</div>
</div>

<%@include file="/WEB-INF/views/includes/adminfooter.jsp"%>